<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <div v-show="!isLogin">
        <a href="javascript:void(0)">注册</a>
        <!--javascript:void(0) 作用:废掉超链接跳转功能  -->
        <a href="javascript:void(0)" @click="login()">登录</a>
    </div>
    <div v-show="isLogin">
        <input type="text" v-model="newName">
        <a href="javascript:void(0)" @click="add()">添加</a>
        <a href="javascript:void(0)" @click="logout()">登出</a>
    </div>
    <ul>
        <li v-for="name in names" v-text="name"></li>
    </ul>
</div>
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js"></script>
<script>
    let v = new Vue({
        el:"div",
        data:{
            names:["刘备","关羽"],
            isLogin:false,
            newName:""
        },
        methods:{
            login:function () {
                v.isLogin = true;
            },
            logout:function () {
                v.isLogin = false;
            },
            add:function () {
                //把用户输入的内容添加到数组中
                v.names.push(v.newName);
            }
        }
    })
</script>
</body>
</html>